<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <body>

        <ui:composition template="./adminTemplate.xhtml">

            <ui:define name="title">
                List Driver
            </ui:define>

            <ui:define name="contain">
                <h:form id="form">
                    <h2 class="ico_mug">List Driver</h2>
                    <p:messages autoUpdate="true" showDetail="true" showSummary="true"></p:messages>
                    <p:dataTable var="dr" value="#{driversController.listDr}" id="table-item"
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                 rowsPerPageTemplate="5,10,15" paginator="true" rows="10">   
                        <p:column style="text-align: center">  
                            <f:facet name="header">  
                                ID 
                            </f:facet>  
                            <h:outputText value="#{dr.id}" />  
                        </p:column> 
                        <p:column>  
                            <f:facet name="header">  
                                Name Driver  
                            </f:facet>  
                            <h:outputText value="#{dr.name}" />  
                        </p:column> 
                        <p:column>  
                            <f:facet name="header">  
                                ContactPerson  
                            </f:facet>  
                            <h:outputText value="#{dr.contactPerson}"/>
                        </p:column> 
                        <p:column>  
                            <f:facet name="header">  
                                Address  
                            </f:facet>  
                            <h:outputText value="#{dr.address}" />  
                        </p:column> 
                        <p:column>  
                            <f:facet name="header">  
                                City  
                            </f:facet>  
                            <h:outputText value="#{dr.city}"/>
                        </p:column>
                        <p:column>  
                            <f:facet name="header">  
                                Mobile 
                            </f:facet>  
                            <h:outputText value="#{dr.mobile}" />  
                        </p:column> 
                        <p:column>  
                            <f:facet name="header">  
                                Telephone
                            </f:facet>  
                            <h:outputText value="#{dr.telephone}" />  
                        </p:column> 
                        <p:column>  
                            <f:facet name="header">  
                                Experience  
                            </f:facet>  
                            <h:outputText value="#{dr.experience}" />  
                        </p:column> 
                        <p:column>  
                            <f:facet name="header">  
                                Description  
                            </f:facet>  
                            <h:outputText value="#{dr.description}" />  
                        </p:column> 
                        <p:column style="text-align: center">  
                            <f:facet name="header">  
                                Status  
                            </f:facet>  
                            <img src="img/#{dr.status}.png" border="0" /> 
                        </p:column>
                        <p:column style="text-align: center;width: 60px">  
                            <f:facet name="header">  
                                Action  
                            </f:facet>  
                            <h:commandLink action="detailDriver">
                                <f:setPropertyActionListener value="#{dr}" target="#{driverBean.driver}" />
                                <img src="img/detail.png" alt="edit"/>
                            </h:commandLink>
                            <p:commandLink action="#{requestController.selectedID(dr.id)}" oncomplete="confirmation.show()">
                                <img src="img/delete.png" alt="trash"/>
                            </p:commandLink>
                            <h:commandLink actionListener="#{driverBean.edit(dr)}">
                                <img src="img/edit.png" alt="edit"/>
                            </h:commandLink>
                        </p:column> 
                    </p:dataTable>    
                    <p:confirmDialog id="confirmation" message="Are you sure to delete this Driver?"  
                                     header="Delete Driver" severity="alert" widgetVar="confirmation" > 
                        <p:commandButton value="Yes Sure" update=":form:table-item" oncomplete="confirmation.hide()"  
                                         actionListener="#{requestController.deleteDriver}" />  
                        <p:commandButton value="Not Yet" onclick="confirmation.hide()" type="button" />   
                    </p:confirmDialog> 

                    <p:fieldset legend="Edit Information">
                        <table cellpadding="5"> 
                            <tbody>
                                <tr>
                                    <td style="width: 80px"><h:outputLabel value="ID:"/></td>
                                    <td style="width: 200px"><p:inputText value="#{driverBean.id}"/></td>
                                    <td style="width: 80px"><h:outputLabel value="City"/></td>
                                    <td><p:inputText id="city" value="#{driverBean.city}"/> </td>
                                </tr>
                                <tr>
                                    <td><h:outputLabel value="Driver's Name:"/></td>
                                    <td><p:inputText id="name" value="#{driverBean.name}"/> </td>
                                    <td><h:outputLabel value="Mobile:"/></td>
                                    <td><p:inputText id="mobile" value="#{driverBean.mobile}"/></td>
                                </tr>
                                <tr>
                                    <td> <h:outputLabel value="Contact Person:"/></td>
                                    <td><p:inputText id="contact" value="#{driverBean.contactPerson}"/></td>
                                    <td><h:outputLabel value="Telephone:"/></td>
                                    <td><p:inputText id="telephone" value="#{driverBean.telephone}"/></td>  
                                </tr>

                                <tr>
                                    <td><h:outputLabel value="Address:"/></td>
                                    <td><p:inputText id="address" value="#{driverBean.address}"/>   </td>
                                    <td><h:outputLabel value="Experience:"/></td>
                                    <td><p:inputText id="experience" value="#{driverBean.experience}"/></td>
                                </tr>                                                               
                                <tr>
                                    <td><h:outputLabel value="Description"/></td>
                                    <td><p:inputTextarea id="description" value="#{driverBean.description}"/></td>
                                    <td><h:outputLabel value="Status"/></td>
                                    <td><p:selectOneRadio value="#{driverBean.status}" id="se" label="status">  
                                            <f:selectItem itemLabel="Accept" itemValue="true" />  
                                            <f:selectItem itemLabel="Deny" itemValue="false" />                                       
                                        </p:selectOneRadio></td>
                                </tr>                                
                                <tr>
                                    <td><p:commandButton ajax="false" value="Update" actionListener="#{requestController.editSubmit()}"/>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </p:fieldset>                     
                </h:form>

            </ui:define>
        </ui:composition>

    </body>
</html>
